﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace Adams.Admin.DataAccess.Console
{
    public static class Layout
    {
        public static Adams.Admin.DataTransfer.Console.Shared.LayoutPageLoad LayoutPageLoad(int userId)
        {
            var data = new Adams.Admin.DataTransfer.Console.Shared.LayoutPageLoad();

            data.WebUrl = Adams.Shared.Config.GetAppSetting("WebUrl");

            using (DataSet ds = DB.RunDataSet(@"
SELECT FirstName, LastName, Email
FROM Console.Users
WHERE UserID = @UserID
",
                   CommandType.Text,
                   DB.CreateParameter("@UserID", userId, SqlDbType.Int)))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    data.UserID = userId;
                    data.FirstName = dr["FirstName"].DbString();
                    data.LastName = dr["LastName"].DbString();
                    data.Email = dr["Email"].DbString();
                }
            }

            return data;
        }
    }
}
